package com.group9.handinhand.controller.form;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;

import com.group9.handinhand.service.so.EventSO;
/**
 * @ class EventCreateForm
 * */
public class EventCreateForm {
	
	EventSO event = new EventSO();
	String selectedTags;
	String startingDay;
	String startingHour;
	String endingDay;
	String endingHour;
	/**
	 * A getter method.
	 * @return event
	 */
	public EventSO getEvent() {
		return event;
	}
	/**
	 * A setter method.
	 * @param event
	 */
	public void setEvent(EventSO event) {
		this.event = event;
	}
	/**
	 * A getter method.
	 * @return Starting day for the event.
	 */
	public String getStartingDay() {
		return startingDay;
	}
	/**
	 * A setter method.
	 * @param startingDay
	 */
	public void setStartingDay(String startingDay) {
		this.startingDay = startingDay;
	}
	/**
	 * A getter method
	 * @return A starting hour of the event
	 */
	public String getStartingHour() {
		return startingHour;
	}
	/**
	 * A setter method 
	 * @param startingHour
	 */
	public void setStartingHour(String startingHour) {
		this.startingHour = startingHour;
	}
	/**
	 * A getter method.
	 * @return Ending date of the event
	 */
	public String getEndingDay() {
		return endingDay;
	}
	/**
	 * A Setter method
	 * @param endingDay
	 */
	public void setEndingDay(String endingDay) {
		this.endingDay = endingDay;
	}
	/**
	 * A getter method.
	 * @return  Ending hour of the event.
	 */
	public String getEndingHour() {
		return endingHour;
	}
	/**
	 * A setter method.
	 * @param endingHour
	 */
	public void setEndingHour(String endingHour) {
		this.endingHour = endingHour;
	}
	/**
	 * To string method which converts EventCreateForm to a string
	 */
	@Override
	public String toString() {
		return "EventCreateForm [event=" + event + ", startingDay="
				+ startingDay + ", startingHour=" + startingHour
				+ ", endingDay=" + endingDay + ", endingHour=" + endingHour
				+ "]";
	}
	/**
	 * A set method.
	 * Sets the starting and ending dates which include starting and ending days and hours also.
	 */
	public void setStartAndEndDates() {
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
		
		String startingDate = startingDay + " " + startingHour;
		String endingDate = endingDay + " " + endingHour;
		
		try {
			event.setStartingTime(dateFormat.parse(startingDate));
			event.setEndingTime(dateFormat.parse(endingDate));
		} catch (ParseException e) {
			e.printStackTrace();
		}
		
	}
	/**
	 * A getter method.
	 * @return selectedTags
	 */
	public String getSelectedTags() {
		return selectedTags;
	}
	/**
	 * A setter method.
	 * @param selectedTags
	 */
	public void setSelectedTags(String selectedTags) {
		this.selectedTags = selectedTags;
	}
	/**
	 * A getter method.
	 * @return a list of selected tags as a array
	 */
	public List<String> getSelectedTagsAsList() {
		String[] tags = selectedTags.split(",");
		return Arrays.asList(tags);
	}
	

}
